package com.sgb.knowledgeshare.viewmodel;

import androidx.lifecycle.ViewModel;

import com.sgb.knowledgeshare.ShareConfig;
import com.sgb.knowledgeshare.view.activity.ShareUserVideoEditActivity;
import com.swgk.core.base.api.ICallBack;
import com.swgk.core.base.model.entity.BaseEntity;
import com.swgk.core.dialog.DialogHelper;
import com.swgk.core.util.MToast;
import com.swgk.core.view.entity.VideoListEntity;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by fq on 2020/9/25 0025
 * Description： 分享-个人中心-用户视频编辑
 */
public class ShareUserVideoEditModel extends ViewModel {

    ShareUserVideoEditActivity shareuservideoeditactivity;
    public void setActivity(ShareUserVideoEditActivity shareUserVideoEditActivity) {
        shareuservideoeditactivity = shareUserVideoEditActivity;
    }
    //获取用户视频列表信息
    public void getVideoListData(int page, String userid) {
        Map map = new HashMap();
        map.put("pageNum", page);
        map.put("pageSize", "20");
        map.put("userNo", userid);
        map.put("type", 0);
        map.put("videoId", "");
        ShareConfig.getInstance().getApi().getmyVodList(map).enqueue(new ICallBack<BaseEntity<VideoListEntity>>() {
            @Override
            public void onSuccess(BaseEntity<VideoListEntity> data) {
                if (data.getData() == null) {
                    return;
                }
                if (data.getState().equals(ShareConfig.RESPONSE_OK)) {
                    shareuservideoeditactivity.setVideoListData(data.getData().getRecords());
                }
            }
        });
    }

//    删除视频的操作
    public void deleteMyVideo(List<Long> delectList) {
        DialogHelper.showProgressDialog(shareuservideoeditactivity, null, "删除中...", 0, true, null).setCanceledOnTouchOutside(false);
        ShareConfig.getInstance().getApi().getDeleteMyVideo(delectList).enqueue(new ICallBack<BaseEntity>() {
            @Override
            public void onSuccess(BaseEntity data) {
                DialogHelper.dismissProgressDialog();
                if (data.getData() == null) {
                    return;
                }
                if (data.getState().equals(ShareConfig.RESPONSE_OK)) {
                    shareuservideoeditactivity.VideoInfoList();
                }
            }
        });
    }


}
